﻿//-----------------------------------------------------------------------
// <copyright file="Items.cs" company="tuliprules.org">
//     Copyright (c) 2010 tuplelister, tuliprules.org.
// </copyright>
// <summary>This is the Items class.</summary>
//-----------------------------------------------------------------------

namespace Tulip.Engine.Models.ClosedWorld
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Globalization;
    using System.Reflection;
    using Collections;

    /// <summary>
    /// Top-level object representing a rules model.
    /// </summary>
    /// <remarks>A rules model provides an abstract model of the tuple list comprehension monad that will be generated to execute a given rule set.</remarks>
    public class Items : ElementBase
    {
        /// <summary>
        /// Collection of assembly references.
        /// </summary>
        private readonly AssemblyReferences assemblyReferences;

        /// <summary>
        /// Collection of entity definitions.
        /// </summary>
        private readonly ClassFrames classFrameCollection;

        /// <summary>
        /// Collection of tuple definitions.
        /// </summary>
        private readonly Tuples tupleCollection;

        /// <summary>
        /// Collection of type descriptions.
        /// </summary>
        private readonly Types types;

        /// <summary>
        /// Collections of production definitions.
        /// </summary>
        private readonly Productions productions;

        /// <summary>
        /// Collections of relation definitions.
        /// </summary>
        private readonly Relations relations;

        /// <summary>
        /// Initializes a new instance of the Items class.
        /// </summary>
        public Items()
        {
            this.assemblyReferences = new AssemblyReferences();
            this.classFrameCollection = new ClassFrames();
            this.tupleCollection = new Tuples();
            this.types = new Types();
            this.productions = new Productions();
            this.relations = new Relations();
        }

        /// <summary>
        /// Gets a collection of assembly references.   These references are available for 
        /// use for .NET types in the runtime model.
        /// </summary>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public IList<AssemblyReference> AssemblyReferences 
        {  
            get
            {
                return this.assemblyReferences;
            } 
        }

        /// <summary>
        /// Gets a collection of class frame definitions.   Class frames are an ontological
        /// construct which represent entities.
        /// </summary>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public IList<Frame> ClassFrames
        {
            get
            {
                return this.classFrameCollection;
            }
        }

        /// <summary>
        /// Gets a collection of tuple definitions.   Tuples are related to entities, but 
        /// define the actual data structures used within the runtime engine.   For example,
        /// a tuple definition might cater for the resuklts of a join between multiple
        /// entities.
        /// </summary>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public IList<Tuple> Tuples 
        { 
            get
            {
                return this.tupleCollection;
            } 
        }

        /// <summary>
        /// Gets a collection of .NET type descriptions.   Entities are bound to .NET types
        /// and members.
        /// </summary>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public IList<Type> Types 
        { 
            get 
            {
                return this.types; 
            } 
        }

        /// <summary>
        /// Gets a collection of production definitions.   Productions extend given
        /// tuples with additional semantics for actions, salience, etc.
        /// </summary>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public IList<Production> Productions 
        { 
            get 
            {
                return this.productions; 
            } 
        }

        /// <summary>
        /// Gets a collection of relation definitions.   Relations define the 
        /// working memory of the engine and store tuples.
        /// </summary>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public IList<Relation> Relations 
        { 
            get 
            {
                return this.relations; 
            } 
        }

        /// <summary>
        /// Gets or sets the functions associated with the model.
        /// </summary>
        public Functions Functions { get; set; }

        /// <summary>
        /// Gets or sets the conflict resolution metadata in the runtime model.
        /// </summary>
        public ConflictResolutionMetadata ConflictResolution { get; set; }

        /// <summary>
        /// Gets or sets information about a specific culture. The information includes the names for the culture, 
        /// the writing system, the calendar used, and formatting for dates and sort strings.
        /// </summary>
        public CultureInfo CultureInfo { get; set; }

        /// <summary>
        /// Gets or sets the processor and bits-per-word of the platform targeted by code generated by this model.
        /// </summary>
        public ProcessorArchitecture ProcessorArchitecture { get; set; }

        ///// <summary>
        ///// Encapsulates access to a public or private key pair used to sign strong name assemblies. 
        ///// </summary>
        // public StrongNameKeyPair StrongNameKeyPair { get; set; }

        /// <summary>
        /// Gets the version of the model.
        /// </summary>
        /// <value>The System.Version representing the four part version number of the model.</value>
        public Version Version
        {
            get
            {
                return new Version(this.Major, this.Minor, this.Build, this.Revision);
            }
        }

        /// <summary>
        /// Gets or sets the the high-level rule language content which was transformed to create the model.
        /// </summary>
        /// <value>The rule set over which the model was created.</value>
        public int RuleSet { get; set; }

        /// <summary>
        /// Gets or sets the major version value of the version number.   Generally incremented to represent a new version of the model that is not backwardly compatible with previous versions.
        /// </summary>
        /// <value>The major version value of the version number.</value>
        public int Major { get; set; }

        /// <summary>
        /// Gets or sets the minor version value of the version number.   Generally incremented to indicate a new version of the model that is backwardly compatible with the previous version.
        /// </summary>
        /// <value>The minor version value of the version number.</value>
        public int Minor { get; set; }

        /// <summary>
        /// Gets or sets the build value of the version number.   The third part of the version number.   Generally used to specify incremental builds during development, and to identify Quick Fix Engineering builds in production.
        /// </summary>
        /// <value>The build value of the version number.</value>
        public int Build { get; set; }

        /// <summary>
        /// Gets or sets the revision value of the version number.   The fourth part of the version number.   Generally used to differentiate between otherwise identical builds designed to target different runtime environmebnts.
        /// </summary>
        /// <remarks></remarks>
        /// <value>The revision value of the version number.</value>
        public int Revision { get; set; }

        /// <summary>
        /// Gets or sets the date and time at which the model was created.   If unknown, the value is set to DateTime.Min.
        /// </summary>
        /// <value>A DateTime value representing the creation date of the model.</value>
        public DateTime Created { get; set; }

        /// <summary>
        /// Gets or sets the date and time at which the model was last modified.  If unknown, the value is set to DateTime.Min.
        /// </summary>
        /// <value>A DateTime value representing the modification date of the model.</value>
        public DateTime Modified { get; set; }

        /// <summary>
        /// Gets or sets the date and time at which the model was last accessed.   If unknown, the value is set to DateTime.Min.
        /// </summary>
        /// <value>A DateTime value representing the last access date of the model.</value>
        public DateTime Accessed { get; set; }
    }
}
